Passed
Push — development ( 26403f...98b3d9 )
by Vad
08:03 queued 49s
created

CitiesService.findAll   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1 7
import { Injectable } from '@nestjs/common';
2 7
import { InjectRepository } from '@nestjs/typeorm';
3 7
import { Repository } from 'typeorm';
4 7
import { City } from './entities/city.entity';
5
6
@Injectable()
7 7
export class CitiesService {
8
  constructor(
9
    @InjectRepository(City)
10 3
    private readonly cityRepository: Repository<City>,
11
  ) {}
12
13
  async findAll(): Promise<City[]> {
14 1
    return await this.cityRepository.find();
15
  }
16
17
  async createCity(data?: Partial<City>): Promise<City> {
18 1
    const city = this.cityRepository.create(data);
19 1
    return await this.cityRepository.save(city);
20
  }
21
}
22